<!DOCTYPE HTML>
<html>
<!--
-->
<head>
  <title>Test for preference not to use document colors</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <style type="text/css">

  #one, #three { background: blue; color: yellow; border: thin solid red; -moz-column-rule: 2px solid green; text-shadow: 2px 2px green; box-shadow: 3px 7px blue; }
  #two { background: transparent; border: thin solid; }
  #five, #six {border: thick solid red; border-inline-start-color:green; border-inline-end-color:blue}
  #seven {
    border: 3px solid;
    -moz-border-top-colors: blue aqua fuchsia;
    -moz-border-right-colors: aqua blue fuchsia;
    -moz-border-bottom-colors: blue fuchsia aqua;
    -moz-border-left-colors: fuchsia blue blue;
  }

  /* XXX also test rgba() */

  </style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=58048">Mozilla Bug 58048</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=255411">Mozilla Bug 255411</a>
<div id="display">

<div id="one">Hello</div>
<div id="two">Hello</div>
<input id="three" type="button" value="Hello">
<input id="four" type="button" value="Hello">
<div id="five" dir="ltr">Hello</div>
<div id="six" dir="rtl">Hello</div>
<div id="seven">Hello</div>

</div>
<pre id="test">
<script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

var cs1 = getComputedStyle(document.getElementById("one"), "");
var cs2 = getComputedStyle(document.getElementById("two"), "");
var cs3 = getComputedStyle(document.getElementById("three"), "");
var cs4 = getComputedStyle(document.getElementById("four"), "");
var cs5 = getComputedStyle(document.getElementById("five"), "");
var cs6 = getComputedStyle(document.getElementById("six"), "");
var cs7 = getComputedStyle(document.getElementById("seven"), "");

SpecialPowers.pushPrefEnv({'set': [['browser.display.document_color_use', 1]]}, part1);

var transparentBackgroundColor;
var inputBackgroundColor, inputColor, inputBorderTopColor;
var inputBorderRightColor, inputBorderLeftColor, inputBorderBottomColor;

function part1()
{

    isnot(cs1.backgroundColor, cs2.backgroundColor, "background-color applies");
    isnot(cs1.color, cs2.color, "color applies");
    isnot(cs1.borderTopColor, cs2.borderTopColor, "border-top-color applies");
    isnot(cs1.borderRightColor, cs2.borderRightColor,
          "border-right-color applies");
    isnot(cs1.borderLeftColor, cs2.borderLeftColor,
          "border-left-color applies");
    isnot(cs1.borderBottomColor, cs2.borderBottomColor,
          "border-top-color applies");
    isnot(cs1.MozColumnRuleColor, cs2.MozColumnRuleColor,
          "-moz-column-rule-color applies");
    isnot(cs1.textShadow, cs2.textShadow,
          "text-shadow applies");
    isnot(cs1.boxShadow, cs2.boxShadow,
          "box-shadow applies");
    is(cs1.borderTopColor, cs3.borderTopColor, "border-top-color applies");
    is(cs1.borderRightColor, cs3.borderRightColor,
       "border-right-color applies");
    is(cs1.borderLeftColor, cs3.borderLeftColor,
       "border-left-color applies");
    is(cs1.borderBottomColor, cs3.borderBottomColor, 
       "border-top-color applies");
    is(cs1.MozColumnRuleColor, cs3.MozColumnRuleColor,
       "-moz-column-rule-color applies");
    is(cs1.textShadow, cs3.textShadow,
       "text-shadow applies");
    is(cs1.boxShadow, cs3.boxShadow,
       "box-shadow applies");
    isnot(cs5.borderRightColor, cs2.borderRightColor,
          "border-inline-end-color applies");
    isnot(cs5.borderLeftColor, cs2.borderLeftColor,
          "border-inline-start-color applies");    
    isnot(cs6.borderRightColor, cs2.borderRightColor,
          "border-inline-start-color applies");
    isnot(cs6.borderLeftColor, cs2.borderLeftColor,
          "border-inline-end-color applies");
    isnot(cs7.MozBorderTopColors, cs2.MozBorderTopColors,
          "-moz-border-top-colors applies");
    isnot(cs7.MozBorderRightColors, cs2.MozBorderRightColors,
          "-moz-border-right-colors applies");
    isnot(cs7.MozBorderBottomColors, cs2.MozBorderBottomColors,
          "-moz-border-bottom-colors applies");
    isnot(cs7.MozBorderLeftColors, cs2.MozBorderLeftColors,
          "-moz-border-left-colors applies");
    is(cs1.color, cs3.color, "color applies");
    is(cs1.backgroundColor, cs3.backgroundColor, "background-color applies");
    isnot(cs3.backgroundColor, cs4.backgroundColor, "background-color applies");
    isnot(cs3.color, cs4.color, "color applies");
    isnot(cs3.borderTopColor, cs4.borderTopColor, "border-top-color applies");
    isnot(cs3.borderRightColor, cs4.borderRightColor,
          "border-right-color applies");
    isnot(cs3.borderLeftColor, cs4.borderLeftColor,
          "border-left-color applies");
    isnot(cs3.borderBottomColor, cs4.borderBottomColor,
          "border-bottom-color applies");
    transparentBackgroundColor = cs2.backgroundColor;
    inputBackgroundColor = cs4.backgroundColor;
    inputColor = cs4.color;
    inputBorderTopColor = cs4.borderTopColor;
    inputBorderRightColor = cs4.borderRightColor;
    inputBorderLeftColor = cs4.borderLeftColor;
    inputBorderBottomColor = cs4.borderBottomColor;
    SpecialPowers.pushPrefEnv({'set': [['browser.display.document_color_use', 2]]}, part2);
}

function part2()
{
    isnot(cs1.backgroundColor, cs2.backgroundColor, "background-color transparency preserved (opaque)");
    is(cs2.backgroundColor, transparentBackgroundColor, "background-color transparency is preserved (transparent)");
    is(cs1.color, cs2.color, "color is blocked");
    is(cs1.borderTopColor, cs2.borderTopColor, "border-top-color is blocked");
    is(cs1.borderRightColor, cs2.borderRightColor,
       "border-right-color is blocked");
    is(cs1.borderLeftColor, cs2.borderLeftColor,
       "border-left-color is blocked");
    is(cs5.borderRightColor, cs2.borderRightColor,
       "border-inline-end-color is blocked");
    is(cs5.borderLeftColor, cs2.borderLeftColor,
       "border-inline-start-color is blocked");
    is(cs6.borderRightColor, cs2.borderRightColor,
       "border-inline-start-color is blocked");
    is(cs6.borderLeftColor, cs2.borderLeftColor,
       "border-inline-end-color is blocked");
    is(cs7.MozBorderTopColors, cs2.MozBorderTopColors,
       "-moz-border-top-colors is blocked");
    is(cs7.MozBorderRightColors, cs2.MozBorderRightColors,
       "-moz-border-right-colors is blocked");
    is(cs7.MozBorderBottomColors, cs2.MozBorderBottomColors,
       "-moz-border-bottom-colors is blocked");
    is(cs7.MozBorderLeftColors, cs2.MozBorderLeftColors,
       "-moz-border-left-colors is blocked");
    is(cs1.borderBottomColor, cs2.borderBottomColor,
       "border-bottom-color is blocked");
    is(cs1.MozColumnRuleColor, cs2.MozColumnRuleColor,
       "-moz-column-rule-color is blocked");
    is(cs1.textShadow, cs2.textShadow,
       "text-shadow is blocked");
    is(cs1.boxShadow, cs2.boxShadow,
       "box-shadow is blocked");
    is(cs3.backgroundColor, cs1.backgroundColor, "background-color transparency preserved (opaque)");
    is(cs3.color, cs4.color, "color is blocked");
    is(cs3.borderTopColor, cs4.borderTopColor, "border-top-color is blocked");
    is(cs3.borderRightColor, cs4.borderRightColor,
       "border-right-color is blocked");
    is(cs3.borderLeftColor, cs4.borderLeftColor,
       "border-left-color is blocked");
    is(cs3.borderBottomColor, cs4.borderBottomColor,
       "border-bottom-color is blocked");
    is(cs4.backgroundColor, inputBackgroundColor, "background-color not broken on inputs");
    is(cs4.color, inputColor, "color not broken on inputs");
    is(cs4.borderTopColor, inputBorderTopColor, "border-top-color not broken on inputs");
    is(cs4.borderRightColor, inputBorderRightColor,
       "border-right-color not broken on inputs");
    is(cs4.borderLeftColor, inputBorderLeftColor,
       "border-left-color not broken on inputs");
    is(cs4.borderBottomColor, inputBorderBottomColor,
       "border-bottom-color not broken on inputs");

    SimpleTest.finish();
}

</script>
</pre>
</body>
</html>
